/**
 * 
 */
package com.norteksoft.erm.model;

import java.sql.ResultSet;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * @author xujl
 * 为用户可将自己拥有的可委托功能权限委托给其他用户的实体
 */
public class MyFuncPerm {
	
	private Long rsID;//资源ID
	
	private String resourcename; //资源名称
	
	private String type; //资源名称
	private String pname; //资源名称
	
	private String authoritytype;//授权类型
	private String parentID;// 资源的父ID 
	private String resourceID;// 资源ID funcation_xxxx
	private String actionPath;// 资源路径
	private String isOpen;
	private String memo;
	private String grantable;// 是否允许委托，true/false
	private String createBy;// 谁做的授权？
	private Integer displayOrder;// 显示排序
	private String isNav; //是否在导航显示
	public int hashCode() {
		return new HashCodeBuilder().append(rsID).append(resourcename).append(
				type).append(pname).append(authoritytype).append(parentID)
				.append(resourceID).append(actionPath).append(isOpen).append(
						memo).append(grantable).append(createBy).toHashCode();
	}
	public MyFuncPerm(ResultSet set){
		try {
			this.setRsID(new Long(set.getLong("RSID")));
			this.setAuthoritytype(set.getString("AUTHORITYTYPE"));
			this.setGrantable(set.getString("GRANTABLE"));
			this.setResourcename(set.getString("RESOURCENAME"));
			this.setPname(set.getString("PNAME"));
			this.setCreateBy(set.getString("CREATEBY"));
			this.setMemo(set.getString("MEMO"));
			this.setResourceID(set.getString("RESOURCEID"));
			this.setParentID(set.getString("PARENTID"));
			this.setIsNav(set.getString("ISNAV"));
			//this.setDisplayOrder(set.getBigDecimal("DISPLAYORDER").toBigInteger());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MyFuncPerm other = (MyFuncPerm) obj;
		if(!rsID.equals(other.rsID))
			return false;
		return true;
	}
	public MyFuncPerm(ResultSet set,int i){
		try {
			
			String string = set.getString("DISPLAYORDER");
			
			this.setRsID(new Long(set.getLong("RSID")));
			this.setAuthoritytype(set.getString("AUTHORITYTYPE"));
			this.setGrantable(set.getString("GRANTABLE"));
			this.setResourcename(set.getString("RESOURCENAME"));
			this.setPname(set.getString("PNAME"));
			this.setCreateBy(set.getString("CREATEBY"));
			this.setIsOpen(set.getString("ISOPEN"));
			this.setMemo(set.getString("MEMO"));
			this.setActionPath(set.getString("ACTIONPATH"));
			this.setResourceID(set.getString("RESOURCEID"));
			this.setType(set.getString("TYPE"));
			this.setIsNav(set.getString("ISNAV"));
			if(StringUtils.isNotEmpty(string))
				this.setDisplayOrder(new Integer(string));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * @return the resourcename
	 */
	public String getResourcename() {
		return resourcename;
	}

	/**
	 * @param resourcename the resourcename to set
	 */
	public void setResourcename(String resourcename) {
		this.resourcename = resourcename;
	}

	/**
	 * @return the pname
	 */
	public String getPname() {
		return pname;
	}

	/**
	 * @param pname the pname to set
	 */
	public void setPname(String pname) {
		this.pname = pname;
	}

	/**
	 * @return the authoritytype
	 */
	public String getAuthoritytype() {
		return authoritytype;
	}

	/**
	 * @param authoritytype the authoritytype to set
	 */
	public void setAuthoritytype(String authoritytype) {
		this.authoritytype = authoritytype;
	}


	
//	private String grantScope;// 委托范围，为空表示不限，值可以是GROUP_groupcode/ROLE_rolecode

//	private String starred;// 已加星标？true/false
	/**
	 * @return the rsID
	 */
	public Long getRsID() {
		return rsID;
	}

	/**
	 * @param rsID the rsID to set
	 */
	public void setRsID(Long rsID) {
		this.rsID = rsID;
	}



	/**
	 * @return the grantable
	 */
	public String getGrantable() {
		return grantable;
	}

	/**
	 * @param grantable the grantable to set
	 */
	public void setGrantable(String grantable) {
		this.grantable = grantable;
	}
	/**
	 * @param createBy the createBy to set
	 */
	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}
	/**
	 * @return the createBy
	 */
	public String getCreateBy() {
		return createBy;
	}
	/**
	 * @param memo the memo to set
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}
	/**
	 * @return the memo
	 */
	public String getMemo() {
		return memo;
	}
	/**
	 * @param isOpen the isOpen to set
	 */
	public void setIsOpen(String isOpen) {
		this.isOpen = isOpen;
	}
	/**
	 * @return the isOpen
	 */
	public String getIsOpen() {
		return isOpen;
	}
	/**
	 * @param actionPath the actionPath to set
	 */
	public void setActionPath(String actionPath) {
		this.actionPath = actionPath;
	}
	/**
	 * @return the actionPath
	 */
	public String getActionPath() {
		return actionPath;
	}
	/**
	 * @param resourceID the resourceID to set
	 */
	public void setResourceID(String resourceID) {
		this.resourceID = resourceID;
	}
	/**
	 * @return the resourceID
	 */
	public String getResourceID() {
		return resourceID;
	}

	public String toString(){
		return rsID+":"+resourcename+":"+authoritytype+":"+grantable;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}
	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}
	/**
	 * @param parentID the parentID to set
	 */
	public void setParentID(String parentID) {
		this.parentID = parentID;
	}
	/**
	 * @return the parentID
	 */
	public String getParentID() {
		return parentID;
	}
	public Integer getDisplayOrder() {
		return displayOrder;
	}
	public void setDisplayOrder(Integer displayOrder) {
		this.displayOrder = displayOrder;
	}
	public String getIsNav() {
		return isNav;
	}
	public void setIsNav(String isNav) {
		this.isNav = isNav;
	}

}
